package com.sinothk.gpserver.modules.system.controller;

import com.sinothk.gpserver.modules.system.entity.LoginDto;
import com.sinothk.gpserver.modules.system.entity.LoginVo;
import com.sinothk.gpserver.modules.system.entity.RegisterUserVo;
import com.sinothk.gpserver.modules.system.service.ILoginService;
import com.sinothk.server.support.annotation.callback.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 编写 Liang Y.T.
 * 时间 2021/6/26 2:30 http://192.168.2.135:18092/pg/v10626/comm/login
 */
@Api(tags = "登录相关功能")
@RestController
@RequestMapping("/sys")
@ResponseResult()
public class LoginController {

    private final ILoginService loginService;

    public LoginController(ILoginService loginService) {
        this.loginService = loginService;
    }


    @ApiOperation(value = "登录-手机号密码", notes = "登录-手机号密码")
    @PostMapping(value = "/login")
    public LoginDto login(@RequestBody LoginVo loginVo) {
        return loginService.login(loginVo);
    }

    @ApiOperation(value = "登录-token", notes = "登录-token")
    @PostMapping(value = "/loginAuto")
    public LoginDto loginAuto() {
        return loginService.loginAuto();
    }

    @ApiOperation(value = "注册", notes = "注册")
    @PostMapping(value = "/register")
    public LoginDto register(@RequestBody RegisterUserVo sysUser) {
        return loginService.register(sysUser);
    }
}
